// 属性装饰器


function PropertyDecorator(target: any, propertyKey: string) {
    let value: any;

    Object.defineProperty(target, propertyKey, {
        get() {
            return value;
        },
        set(newValue) {
            console.warn(`禁止赋值给 ${propertyKey}，操作被拦截`);
            // 不设置 value = newValue，所以实际值不会改变
        },
        configurable: true,
        enumerable: true
    });
}

class Property {
    @PropertyDecorator
    useProertyName: string = "asdad"
}


const useProperty = new Property()

useProperty.useProertyName = "Dasdas"
console.log(useProperty.useProertyName)